{extend name='common/_container'} {block name="content"}
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <div class="row" id="searchGroup">
                            <!--<div class="col-sm-2">
                                <div class="input-group">
                                    <div class="input-group-btn">
                                        <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">昵称</button>
                                    </div>
                                    <input type="text" autocomplete="off" class="form-control" id="nickname" placeholder="昵称" />
                                </div>
                            </div>-->
                    <!--        <div class="col-sm-2">
                                <div class="input-group">
                                    <div class="input-group-btn">
                                        <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">手机号</button>
                                    </div>
                                    <input type="text" autocomplete="off" class="form-control" id="phone" placeholder="手机号" />
                                </div>
                            </div>-->
                           <!-- <div class="col-sm-2">
                                <div class="input-group">
                                    <div class="input-group-btn">
                                        <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">状态</button>
                                    </div>
                                    <select class="form-control" id="status">
                                        <option value="">请选择</option>
                                        <option value="1">正常</option>
                                        <option value="0">拉黑</option>
                                    </select>
                                </div>
                            </div>-->


                            <!-- search end -->
                         <!--   <div class="col-sm-1">
                                <button type="button" class="btn btn-success " onclick="CodeGoods.search()" id="">
                                    <i class="fa fa-search"></i>&nbsp;搜索
                                </button>
                            </div>-->
                        </div>

                        <div class="btn-group-sm" id="CodeGoodsTableToolbar" role="group">
                            <!--lwx 添加用户-->
                            <input type="hidden" id="authentication_id" value="{$authentication_id}" name="authentication_id"/>
                        </div>
                        <table id="CodeGoodsTable" data-mobile-responsive="true" data-click-to-select="true">
                            <thead><tr><th data-field="selectItem" data-checkbox="true"></th></tr></thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
    var CodeGoods = {id: "CodeGoodsTable",seItem: null,table: null,layerIndex: -1};
    layui.use(['form', 'upload','layer'], function () {
        var upload = layui.upload;
        var layer = layui.layer

        var uploadInst = upload.render({
            elem: '#import' //绑定元素
            ,accept: 'file'
            ,exts:'xls'
            ,url: Feng.ctxPath + "/Member/import" //上传接口
            ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading
            }
            ,done: function(data){
                layer.closeAll('loading'); //关闭loading
                //上传完毕回调
                if ('00' === data.status) {
                    Feng.success(data.msg, 1000);
                    CodeGoods.table.refresh();
                } else {
                    Feng.error(data.msg + "！", 1000);
                }
            }
            ,error: function(){
                layer.closeAll('loading'); //关闭loading
                //请求异常回调
            }
        });
    });
    var gdata = []
    CodeGoods.choose = function (index) {
        parent.GetTopValue(gdata[index]);
        index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
    CodeGoods.initColumn = function () {
        return [
            {field: 'selectItem', checkbox: true},
            {title: '编号', field: 'uid', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '昵称', field: 'nickname', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '真实名称', field: 'real_name', visible: true, align: 'center', valign: 'middle',sortable: true},
           /* {title: '余额', field: 'balance', visible: true, align: 'center', valign: 'middle',sortable: true},*/
            {title: '手机号', field: 'phone', visible: true, align: 'center', valign: 'middle',sortable: true},
           // {title: '照片', field: 'pic', visible: false, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.picFormatter},
            //{title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.statusFormatter},
          /*  {title: '上级红娘', field: 'matchmaker_id', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '置顶卡名称', field: 'top_card_name', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '置顶卡有效期', field: 'top_card_expiry', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.createtimeFormatter},
            {title: '是否红娘', field: 'is_matchmaker', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_matchmakerFormatter},
            {title: '是否会员', field: 'is_vip', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_vipFormatter},
            {title: '是否家长', field: 'is_parent', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_parentFormatter},
            {title: '是否认证', field: 'is_auth', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_authFormatter},
            {title: '审核状态', field: 'auth_status', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.auth_statusFormatter},
        */    {
                title: '操作',
                field: '',
                visible: true,
                align: 'center',
                valign: 'middle',
                formatter: CodeGoods.buttonFormatter
            },
        ];
    };

    CodeGoods.createtimeFormatter = function(value,row,index) {
        if(value){
            return formatDateTime(value,'Y-m-d H:i:s');
        }
    }

    CodeGoods.buttonFormatter = function (value, row, index) {
        gdata[index] = row
        var str = '';
        str += '<button type="button" class="btn btn-success btn-xs" title="选择"  onclick="CodeGoods.choose(' + index + ')"><i class="fa fa-pencil"></i>&nbsp;选择</button>&nbsp;';
        return str;
    }

    CodeGoods.check = function () {
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        if (selected.length == 0) {
            Feng.info("请先选中表格中的某一记录！");
            return false;
        } else {
            CodeGoods.seItem = selected;
            return true;
        }
    };
    CodeGoods.formParams = function() {
        var queryData = {};
        queryData['offset'] = 0;
        queryData['nickname'] = $("#nickname").val();
        queryData['phone'] = $("#phone").val();
        queryData['status'] = $("#status").val();
        queryData['is_matchmaker'] = $("#is_matchmaker").val();
        queryData['is_vip'] = $("#is_vip").val();
        queryData['vip_number'] = $("#vip_number").val();
        //传递佳人id

        return queryData;
    }
    $(function () {
        var defaultColunms = CodeGoods.initColumn();
        var url = location.search;
        var authentication_id=$("#authentication_id").val();
        var table = new BSTable(CodeGoods.id, Feng.ctxPath + "/Member/indexs" + url, defaultColunms, 20);
        table.setPaginationType("server");
        table.setQueryParams(CodeGoods.formParams());
        CodeGoods.table = table.init();
    });

</script>
{/block}